package com.lcy.reggie.controller;

import com.lcy.reggie.common.Result;
import com.lcy.reggie.dto.UserDto;
import com.lcy.reggie.entity.User;
import com.lcy.reggie.service.UserService;
import com.lcy.reggie.utils.ValidateCodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * ======刘春春大帅逼======
 * ******java学习之旅******
 */

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;


    /**
     *  发送短信验证码
     * @param user
     * @return
     */
    @PostMapping("/sendMsg")
    public Result<String> sendMsg(@RequestBody User user, HttpSession session) {
        return userService.sendMsg(user, session);
    }

    @PostMapping("/login")
    public Result<User> login(@RequestBody UserDto userDto, HttpSession session){
        return userService.login(userDto,session);
    }
}
